| Total Complexity | 2 |
| Total Lines | 16 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | import { Inject } from '@nestjs/common'; |
||
| 6 | |||
| 7 | @CommandHandler(RemoveEventCommand) |
||
| 8 | export class RemoveEventCommandHandler { |
||
| 9 | constructor( |
||
| 10 | @Inject('IEventRepository') |
||
| 11 | private readonly eventRepository: IEventRepository, |
||
| 12 | ) {} |
||
| 13 | |||
| 14 | public async execute({ id }: RemoveEventCommand): Promise<void> { |
||
| 15 | const event = await this.eventRepository.findOneById(id); |
||
| 16 | |||
| 17 | if (!event) { |
||
| 18 | throw new EventNotFoundException(); |
||
| 19 | } |
||
| 20 | |||
| 21 | await this.eventRepository.remove(event); |
||
| 22 | } |
||
| 24 |